package com.fary.producer;

import com.fary.config.RabbitMQCorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class Producer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void topicTest() {
        String msg = "陈氏集团资金增长浮动10%";
        rabbitTemplate.convertAndSend("topic_exchange", "red", msg);

        String msg1 = "陈氏集团在四川的在职职工裁员8%";
        rabbitTemplate.convertAndSend("topic_exchange", "yellow", msg1);

        String msg2 = "陈氏集团在太原的在职职工工资上涨20%";
        rabbitTemplate.convertAndSend("topic_exchange", "blue", msg2, new RabbitMQCorrelationData(UUID.randomUUID().toString()));
    }


}
